var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/Attachment/components/FileView.tsx
var FileView_exports = {};
__export(FileView_exports, {
  FileView: () => FileView
});
module.exports = __toCommonJS(FileView_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_react = require("react");
var import_util = require("../util");
var fileIconMap = {
  doc: import_icons.FileWordFilled,
  docx: import_icons.FileWordFilled,
  xls: import_icons.FileExcelFilled,
  xlsx: import_icons.FileExcelFilled,
  pdf: import_icons.FilePdfFilled,
  zip: import_icons.FileZipFilled,
  png: import_icons.FileImageFilled,
  jpg: import_icons.FileImageFilled,
  jpeg: import_icons.FileImageFilled,
  gif: import_icons.FileImageFilled
};
var colorMap = {
  xls: "#53D39C",
  xlsx: "#53D39C",
  pdf: "#FF7878",
  zip: "#FF7878"
};
function FileView(props) {
  const { style = {}, handlePreview, isPreview = true, data, iconPosition = "left" } = props;
  const { fileType, fileSizeStr } = (0, import_react.useMemo)(() => {
    return {
      fileType: (0, import_util.getFileType)(data.fileName),
      fileSizeStr: (0, import_util.getFileSize)(data.fileSize)
    };
  }, [data]);
  const Icon = fileIconMap[fileType] ? fileIconMap[fileType] : import_icons.FileTextFilled;
  const color = data.status === "fail" ? "#ff3333" : colorMap[fileType] || "#53B7F4";
  const nodes = [
    /* @__PURE__ */ React.createElement("span", { style: { marginRight: 5 }, key: "file-icon" }, /* @__PURE__ */ React.createElement(Icon, { style: { fontSize: 20, color, ...style } })),
    /* @__PURE__ */ React.createElement(
      "span",
      {
        key: "file-fileName",
        title: data.fileName,
        className: `attachment-overflow ${isPreview ? "attachment-preview-file" : ""}`,
        onClick: isPreview ? handlePreview : void 0
      },
      data.fileName
    ),
    /* @__PURE__ */ React.createElement("span", { className: "attachment-file-size", style: { color: "var(--primary-color)" }, key: "file-size" }, "（", fileSizeStr, "）")
  ];
  if (data.status === "done") {
    const iconNode = /* @__PURE__ */ React.createElement(import_icons.CheckCircleFilled, { className: "file-status-icon done", key: "file-done" });
    iconPosition === "left" ? nodes.unshift(iconNode) : nodes.push(iconNode);
  }
  if (data.status === "fail") {
    const iconNode = /* @__PURE__ */ React.createElement(import_icons.CloseCircleFilled, { className: "file-status-icon failed", key: "file-failed" });
    iconPosition === "left" ? nodes.unshift(iconNode) : nodes.push(iconNode);
  }
  return /* @__PURE__ */ React.createElement(React.Fragment, null, nodes, data.status === "uploading" && data.percent !== void 0 && /* @__PURE__ */ React.createElement(
    import_antd.Progress,
    {
      percent: data.percent,
      size: "small",
      status: "active",
      className: `attachment-progress`,
      showInfo: false
    }
  ));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FileView
});
